package org.jivesoftware.smackx.workgroup.packet;

import org.jivesoftware.smack.packet.PacketExtension;
import org.jivesoftware.smack.provider.PacketExtensionProvider;
import org.xmlpull.v1.XmlPullParser;

public class RoomTransfer
  implements PacketExtension
{
  public static final String ELEMENT_NAME = "transfer";
  public static final String NAMESPACE = "http://jabber.org/protocol/workgroup";
  private String invitee;
  private String inviter;
  private String reason;
  private String room;
  private String sessionID;
  private Type type;

  public RoomTransfer(Type paramType, String paramString1, String paramString2, String paramString3)
  {
    this.type = paramType;
    this.invitee = paramString1;
    this.sessionID = paramString2;
    this.reason = paramString3;
  }

  public String getElementName()
  {
    return "transfer";
  }

  public String getInviter()
  {
    return this.inviter;
  }

  public String getNamespace()
  {
    return "http://jabber.org/protocol/workgroup";
  }

  public String getReason()
  {
    return this.reason;
  }

  public String getRoom()
  {
    return this.room;
  }

  public String getSessionID()
  {
    return this.sessionID;
  }

  public String toXML()
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("<").append("transfer").append(" xmlns=\"").append("http://jabber.org/protocol/workgroup");
    localStringBuilder.append("\" type=\"").append(this.type).append("\">");
    localStringBuilder.append("<session xmlns=\"http://jivesoftware.com/protocol/workgroup\" id=\"").append(this.sessionID).append("\"></session>");
    if (this.invitee != null)
      localStringBuilder.append("<invitee>").append(this.invitee).append("</invitee>");
    if (this.inviter != null)
      localStringBuilder.append("<inviter>").append(this.inviter).append("</inviter>");
    if (this.reason != null)
      localStringBuilder.append("<reason>").append(this.reason).append("</reason>");
    localStringBuilder.append("</").append("transfer").append("> ");
    return localStringBuilder.toString();
  }

  public static class Provider
  implements PacketExtensionProvider
  {
    public PacketExtension parseExtension(XmlPullParser paramXmlPullParser)
      throws Exception
    {
      RoomTransfer localRoomTransfer = new RoomTransfer(null);
      RoomTransfer.access$1(localRoomTransfer, RoomTransfer.Type.valueOf(paramXmlPullParser.getAttributeValue("", "type")));
      int i = 0;
      while (true)
      {
        String str;
        label178: 
        do
          while (true)
          {
            do
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      if (i != 0)
                        return localRoomTransfer;
                      paramXmlPullParser.next();
                      str = paramXmlPullParser.getName();
                      if (paramXmlPullParser.getEventType() != 2)
                        break label178;
                      if (!("session".equals(str)))
                        break;
                      RoomTransfer.access$2(localRoomTransfer, paramXmlPullParser.getAttributeValue("", "id"));
                    }
                    if (!("invitee".equals(str)))
                      break;
                    RoomTransfer.access$3(localRoomTransfer, paramXmlPullParser.nextText());
                  }
                  if (!("inviter".equals(str)))
                    break;
                  RoomTransfer.access$4(localRoomTransfer, paramXmlPullParser.nextText());
                }
                if (!("reason".equals(str)))
                  break;
                RoomTransfer.access$5(localRoomTransfer, paramXmlPullParser.nextText());
              }
            while (!("room".equals(str)));
            RoomTransfer.access$6(localRoomTransfer, paramXmlPullParser.nextText());
          }
        while ((paramXmlPullParser.getEventType() != 3) || (!("transfer".equals(str))));
        i = 1;
      }
    }
  }

  public static enum Type
  {
    static
    {
      queue = new Type("queue", 1);
      workgroup = new Type("workgroup", 2);
      Type[] arrayOfType = new Type[3];
      arrayOfType[0] = user;
      arrayOfType[1] = queue;
      arrayOfType[2] = workgroup;
      ENUM$VALUES = arrayOfType;
    }
  }
}